<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('过程列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>对象类型：</p>
                                <input type="text" name="objectName"/>
                            </li>

                            <li>
                                <p>对象类型：</p>
                                <input type="text" name="objectName"/>
                            </li>
                            <!--<li>-->
                                <!--<p>数量：</p>-->
                                <!--<input type="text" name="orderNum"/>-->
                            <!--</li>-->
                            <li>
                                <p>对象状态：</p>
                                <select name="status" th:with="type=${@dict.getType('object_name_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:object:add">
                    <i class="fa fa-plus"></i> 新增对象
                </a>
                <a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="system:object:edit">
                    <i class="fa fa-edit"></i> 修改对象
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:object:import">
                    <i class="fa fa-upload"></i> 导入对象
                </a>
                <a class="btn btn-info" id="expandAllBtn">
                    <i class="fa fa-exchange"></i> 展开/折叠
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-tree-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var addFlag = [[${@permission.hasPermi('system:object:add')}]];
        var detalFlag =[[${@permission.hasPermi('system:object:detal')}]];
        var editFlag = [[${@permission.hasPermi('system:object:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:object:remove')}]];
        var statusDatas = [[${@dict.getType('object_name_status')}]];
        var prefix = ctx + "system/object";

        $(function() {
            var options = {
                code: "objectId",
                parentCode: "parentId",
                expandColumn: "1",
                uniqueId: "objectId",
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove/{id}",
                exportUrl: prefix + "/export",
                detailUrl: prefix + "/detail/{id}",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
//                LikeUrl: prefix + "/list/{id}",
//                detailUrl: prefix + "/getParents",
                modalName: "过程",
                columns: [{
                    field: 'selectItem',
                    radio: true
                },
                    {
                        field : 'objectName',
                        title : '对象名称',
                        align: 'left'
                    },
                    {
                        field : 'aType',
                        title : '对象类型',
                        align: 'right'
                    },

                    {
                        field : 'bType',
                        title : '二级对象类型',
                        align: 'auto'
                    },


//                {
//                    field : 'orderNum',
//                    title : '对象数量',
//                    align: 'left'
//                },
                {
                    field : 'status', 
                    title : '对象状态',
                    align: 'auto',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
//                {
//                    field : 'createBy',
//                    title : '创建者',
//                    align: 'left'
//                },
                {
                    field : 'createTime', 
                    title : '创建时间',
                    align: 'auto'
                },
                {
                    title: '操作',
                    align: 'center',
                    align: 'right',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.objectId + '\')"><i class="fa fa-edit"></i>对象详情</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.objectId + '\')"><i class="fa fa-edit"></i>编辑对象</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.objectId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.treeTable.init(options);
        });
    </script>
     <!-- 导入区域 -->
     <script id="importTpl" type="text/template">
         <form enctype="multipart/form-data" class="mt20 mb10">
             <div class="col-xs-offset-1">
                 <input type="file" id="file" name="file"/>
                 <div class="mt10 pt5">
                     <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                     &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
                 </div>
                 <font color="red" class="pull-left mt10">
                     提示：仅允许导入“xls”或“xlsx”格式文件！
                 </font>
             </div>
         </form>
     </script>
</body>
</html>